package com.briup.day13;

import java.util.Objects;

/**
 * @author lining
 * @date 2024/1/24 14:53
 */
public class Teacher implements Comparable<Teacher>{
    private  int id;
    private String name;

    public int getId() {
        return id;
    }

    public Teacher(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        System.out.println("equals....");
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        return id == teacher.id;
    }

    @Override
    public int hashCode() {
        System.out.println("hashcode...");
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Teacher o) {
        //通过使用比较方法 ，如果返回值为0 树中不存储重复节点。表示相同
        // 大  ---》小
        //  id = 1  id =5 o
        return o.id - this.id;// 4
    }
}
